/**
 * Created by forcht on 2018/7/3.
 */
public class Solution {

    public boolean isPalindrome(String s) {
        s=s.toLowerCase();
        int i=0;
        int j=s.length()-1;
        while (i<j){
            while ((!(s.charAt(i)>='0'&&s.charAt(i)<='9')&&!(s.charAt(i)>='a'&&s.charAt(i)<='z'))&&i<j) i++;
            while ((!(s.charAt(j)>='0'&&s.charAt(j)<='9')&&!(s.charAt(j)>='a'&&s.charAt(j)<='z'))&&i<j) j--;
            if(s.charAt(i)!=s.charAt(j))return false;
            i++;
            j--;
        }
        return true;
    }

    public static void main(String[] args) {
        Solution solution=new Solution();
        System.out.println(solution.isPalindrome("ab"));
    }
}
